﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Ditto.Models.RequestStatus>" %>
<div id="requeststatus">
<% if (Model.Type == Ditto.Models.RequestStatus.StatusType.None)
   { %>

<%: Html.ActionLink("Request", "SubmitRequest", "Items", new { id = Model.ItemID }, null)%> this item

<%} %>

<%else if (Model.Type == Ditto.Models.RequestStatus.StatusType.Requesting)
   { %>

You are now waiting for approval | <%: Html.ActionLink("Cancel", "CancelRequest", "Items", new { id = Model.ItemID }, null)%> request

<%} %>

<%else if (Model.Type == Ditto.Models.RequestStatus.StatusType.Approved)
   { %>

Congratulations, your request has been approved! View <%: Html.ActionLink("transaction", "RelatedTransaction", "Items", new { id = Model.ItemID }, null)%>

<%} %>

<%else { %>

Sorry, your request has been rejected because [give reason here]

<%} %>
</div>

<script type="text/javascript">
    $("#requeststatus a").click(function () {
        $.get($(this).attr("href"), function (response) {
            $("#requeststatus").replaceWith(response);
        });
        return false;
    });
</script>